package cn.gson.crmdemo.model.service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSONArray;

import cn.gson.crmdemo.model.dao.BxDao;
import cn.gson.crmdemo.model.dao.EmpDao;
import cn.gson.crmdemo.model.mapper.BxMapper;
import cn.gson.crmdemo.model.pojo.Emp;
import cn.gson.crmdemo.model.pojo.Quotation;
import cn.gson.crmdemo.model.pojo.Reimbursement;
import cn.gson.crmdemo.model.vo.BxVo;

@Service
@Transactional(rollbackFor=Exception.class)
public class BxService {
	@Autowired
	BxMapper br;
	@Autowired
	BxDao bo;
	@Autowired
	EmpDao edao;
	/**
	 * 查所有
	 * @return
	 */
	public JSONArray selectsp(String reimDate,Integer reimState,Integer a){
		return br.selectsp(reimDate,reimState,a);
	}
	/**
	 * 报销申请查询
	 */
		public JSONArray selectbxsq(String reimDate,Integer reimState,Integer a) {
			return br.selectbxsq(reimDate,reimState,a);
		}
	/**
	 * 修改状态
	 * @return
	 */
	public void xgzt(int a,int b,String c) {
		System.err.println("bh"+c);
		Reimbursement rt=new Reimbursement();
		rt=bo.findById(a).get();
		rt.setReimState(b);
		rt.setReimApproval(c);
		 bo.save(rt);
	}
	/**
	 *报销申请修改状态
	 */
	public void xgzt1(int a,int b){
		System.err.println(a);
		Reimbursement rt=bo.findById(a).get();
		rt.setReimState(b);
	}
	/**
	 * 根据状态查询
	 */
	public JSONArray selectzt(int a) {
		return br.selectzt(a);
		
	}
	
	/**
	 * 审批人
	 */
	public JSONArray selectspr() {
		return br.selectspr();
		
	}
	/**
	 * 申请人
	 */
		public JSONArray selectsqr() {
			return br.selectsqr();
		}
		/**
		 * 添加报销申请
		 */
		public void addbx(BxVo bo) {
			Date a=bo.getReimDate();
			BigDecimal b=bo.getReimMoney();
			int c=bo.getReimName();
			String d=bo.getReimRecord();
			br.insertReimbursement(a, b, c, d);
		}
		/**
		 * 日期模糊查询	
		 */
		public JSONArray selectsqrq(String rq) {
			return br.selectsqrq("%"+rq+"%");
		}
		/**
		 * 查询当前登录人
		 */
		public JSONArray selectsprcx(Integer a) {
			return br.selectsprcx(a);
		}
		/**
		 * 查询申请人
		 */
		public JSONArray selectsqrcx(Integer a) {
			return br.selectsqrcx(a);
		}
		public Integer  selectsqrcxy(String b) {
			return br.selectsqrcxy(b);
		}
				
}
